#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:

    int MLS(vector<int>& arr) {
        sort(arr.begin(), arr.end());
        int right = 1, len = 0, count = 1;
        for (; right < arr.size(); right++)
        {
            if (arr[right] == arr[right - 1]) continue;
            if (arr[right] - 1 == arr[right - 1]) count++;
            else
            {
                len = max(len, count);
                count = 1;
            }
        }
        len = max(len, count);
        return len;
    }
};